package com.sp2p.action.front;

import java.io.IOException;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.xml.rpc.ServiceException;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;

import com.gofull.gateway.sms.util.SMSUtil;
import com.gofull.gateway.wechat.config.WechatConfig;
import com.gofull.gateway.wechat.util.WechatUtils;
import com.shove.Convert;
import com.shove.security.Encrypt;
import com.shove.util.SqlInfusion;
import com.shove.util.UtilDate;
import com.shove.web.util.DesSecurityUtil;
import com.shove.web.util.JSONUtils;
import com.shove.web.util.ServletUtils;
import com.shovesoft.SMS;
import com.sp2p.constants.IConstants;
import com.sp2p.dao.PersonDao;
import com.sp2p.entity.User;
import com.sp2p.service.BBSRegisterService;
import com.sp2p.service.GameService;
import com.sp2p.service.HomeInfoSettingService;
import com.sp2p.service.MailSendService;
import com.sp2p.service.RecommendUserService;
import com.sp2p.service.SendMailService;
import com.sp2p.service.UserIntegralService;
import com.sp2p.service.UserService;
import com.sp2p.service.admin.AdminService;
import com.sp2p.service.admin.RelationService;
import com.sp2p.service.admin.SMSInterfaceService;
import com.sp2p.util.ClientMessages;

/**
 * 用户注册
 * 
 * @author
 * 
 */
public class FrontLongRegisterAction extends BaseFrontAction {
	public static Log log = LogFactory.getLog(FrontLongRegisterAction.class);
	private static final long serialVersionUID = 1L;
	/**
	 */
	protected UserService userService;
	protected SendMailService sendMailService;
	private RecommendUserService recommendUserService;
	private RelationService relationService;
	private HomeInfoSettingService homeInfoSettingService;
	private UserIntegralService userIntegralService;
	private MailSendService mailSendService;
	private BBSRegisterService bbsRegisterService;
	private AdminService adminService;
	private SMSInterfaceService sMsService;
	private GameService gameService;

	public GameService getGameService() {
		return gameService;
	}

	public void setGameService(GameService gameService) {
		this.gameService = gameService;
	}

	public void setsMsService(SMSInterfaceService sMsService) {
		this.sMsService = sMsService;
	}

	public void setMailSendService(MailSendService mailSendService) {
		this.mailSendService = mailSendService;
	}

	public void setUserIntegralService(UserIntegralService userIntegralService) {
		this.userIntegralService = userIntegralService;
	}
	
	public String wechatLogin() throws Exception {
		request().setAttribute("url", WechatConfig.WZ_CODE_URL);
		return SUCCESS;
	}
	
	public String wechatLoginCallback() throws Exception {
		String code = request("code");
		if(null == code || "".equals(code)){
			return "failed";
		}
		
		User user = (User)session().getAttribute("user");
		if(null != user){
			return "index";
		}
		
		Map<String, String> map = WechatUtils.getOauth2AccessToken(
				WechatConfig.WZAPPID, WechatConfig.WZAPPSECRET, code);
		int errcode = Convert.strToInt(map.get("errcode"), 0);
		String unionid = Convert.strToStr(map.get("unionid"), "");
		if (errcode > 0 || "".equals(unionid)) {
			return "failed";
		}
		
		session().setAttribute("unionid", unionid);
		Map<String, String> autoInfo = userService.queryWchatAutoLoginInfo(unionid);
		if (null != autoInfo && autoInfo.size() > 0) {
			int isAuto = Convert.strToInt(autoInfo.get("isAuto"), 0);
			long uid = Convert.strToLong(autoInfo.get("userId"), -1);
			if(isAuto == 1 && uid > 0){
				user = userService.wchatAutoLoginSession(uid);
				session().setAttribute("user", user);
				
				// 在首页显示用户没有读取的通知信息
				Map<String, String> mailCountMap = homeInfoSettingService
						.queryReceiveMailsTotal(user.getId());
				request().getSession().setAttribute("mailCountMap", mailCountMap);
				
				return "index";
			}else{
				return "bind";
			}
		}
		return SUCCESS;
	}

	public String regInit() throws Exception {
		User user = (User) session().getAttribute("user");
		if (user != null) {
			// return "login";
		}
		String param = SqlInfusion.FilteSqlInfusion(request("param"));
		if (StringUtils.isNotBlank(param)) {
			DesSecurityUtil des = new DesSecurityUtil();
			Long userId = Convert.strToLong(des.decrypt(param), -1);
			String userName;
			Map<String, String> map = new HashMap<String, String>();
			try {
				map = userService.queryUserById(userId);
			} catch (Exception e) {
				log.error(e);
				e.printStackTrace();
			}
			userName = map.get("username");
			paramMap.put("refferee", userName);
			session().setAttribute("reffereeParam", userName);
		}
		paramMap.put("param", param);
		return SUCCESS;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	/**
	 * 忘记密码
	 * 
	 * @return
	 */
	public String forget() {
		return SUCCESS;
	}

	public String forgetSendEMl() throws Exception {
		JSONObject obj = new JSONObject();
		Map<String, String> map = null;
		// String username = null;
		Long userId = null;
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		String username = SqlInfusion
				.FilteSqlInfusion(paramMap.get("userName"));
		// 不校验验证码了
		// String code =
		// SqlInfusion.FilteSqlInfusion(paramMap.get("code").toString().trim());
		// String pageId = SqlInfusion.FilteSqlInfusion(paramMap.get("pageId"));
		// String code2 = (String) session().getAttribute(pageId +
		// "_checkCode");
		//		
		// if((code != null && code != "") && (pageId != null && pageId != "")){
		// if(!code.equals(code2)){
		// obj.put("mailAddress", "-2");
		// JSONUtils.printObject(obj);
		// return null;
		// }
		// }
		if (StringUtils.isBlank(email)) {
			obj.put("mailAddress", "0");
			JSONUtils.printObject(obj);
			return null;
		} else {
			// ===截取emal后面地址
			int dd = email.indexOf("@");
			String mailAddress = null;
			if (dd >= 0) {
				mailAddress = "mail." + email.substring(dd + 1);
			}
			// ====
			map = userService.queryPassword(email);
			if (map != null && map.size() > 0) {
				username = map.get("username");
				userId = Convert.strToLong(map.get("id"), -1L);
				DesSecurityUtil des = new DesSecurityUtil();
				String key1 = des.encrypt(userId.toString());
				String key2 = des.encrypt(new Date().getTime() + "");
				String url = getPath(); // request().getRequestURI();
				String VerificationUrl = url + "changePassword.do?username="
						+ username + "&key=" + key1 + "$" + key2;
				sendMailService.sendRetakePasswordVerificationEmail(
						VerificationUrl, username, email);
				session().setAttribute("VerificationUrl", VerificationUrl);
				obj.put("mailAddress", mailAddress);
				JSONUtils.printObject(obj);
				return null;

			} else {
				obj.put("mailAddress", "1");
				JSONUtils.printObject(obj);
				return null;
			}
		}
	}

	public String resetPwdSendMailAgain() throws Exception {
		Map<String, String> userMap = (Map<String, String>) session()
				.getAttribute("findPwdMap");
		String VerificationUrl = (String) session().getAttribute(
				"VerificationUrl");
		if (null == userMap || userMap.size() < 1
				|| StringUtils.isBlank(VerificationUrl)) {
			JSONUtils.printStr("0");
		}
		Map<String, String> map = null;
		Long userId = null;
		int sendMailCount = Convert.strToInt(paramMap.get("sendMailCount"), 0);
		String email = userMap.get("email");
		String username = userMap.get("username");
		if (StringUtils.isBlank(email) || StringUtils.isBlank(username)) {
			JSONUtils.printObject("99");
			return null;
		} else {
			sendMailService.sendRetakePasswordVerificationEmail(
					VerificationUrl, username, email);
			sendMailCount++;
			JSONUtils.printStr(sendMailCount + "");
			return null;

		}
	}

	/**
	 * 发送验证码到邮箱
	 * 
	 * @return
	 * @throws Exception
	 */
	public String sendEmailToMailBox() throws Exception {
		JSONObject obj = new JSONObject();
		Map<String, String> map = null;
		String username = null;
		Long userId = null;
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		String zhuce = SqlInfusion.FilteSqlInfusion(paramMap.get("zhuce"));
		// ===截取emal后面地址
		int dd = email.indexOf("@");
		String mailAddress = null;
		if (dd >= 0) {
			mailAddress = "mail." + email.substring(dd + 1);
		}
		// ====
		map = userService.queryPassword(email);
		if (null != zhuce && zhuce.length() > 0) {
			// username = map.get("username");
			// userId = Convert.strToLong(map.get("id"), -1L);

			Random r = new Random();
			String code = r.nextInt(900000) + "";
			String codeStr = "" + code + " 【工作人员不会索取，请勿泄漏】";
			System.out.println(code);
			sendMailService.sendRegisterVerificationEmailPassWordindex(codeStr,
					username, email);

			if (session().getAttribute("mailCode") != null) {
				session().setAttribute("mailCode", null);
			}
			session().setAttribute("mailCode", code);

			obj.put("mailAddress", '0');
			JSONUtils.printObject(obj);
			return null;
		} else {
			if (map != null && map.size() > 0) {
				username = map.get("username");
				userId = Convert.strToLong(map.get("id"), -1L);

				Random r = new Random();
				String code = r.nextInt(900000) + "";
				String codeStr = "" + code + " 【工作人员不会索取，请勿泄漏】";
				System.out.println(code);
				sendMailService.sendRegisterVerificationEmailPassWordindex(
						codeStr, username, email);

				HttpSession session = request().getSession();
				if (session.getAttribute("mailCode") != null) {
					session.setAttribute("mailCode", null);
				}
				session.setAttribute("mailCode", code);

				obj.put("mailAddress", '0');
				JSONUtils.printObject(obj);
				return null;

			} else {
				obj.put("mailAddress", "1");
				JSONUtils.printObject(obj);
				return null;
			}
		}
	}

	/**
	 * @Title: findPwdByMail
	 * 
	 * @Description: 发送邮件至邮箱后跳转至等待校验界面
	 * 
	 * @return String
	 */
	public String findPwdByMail() {
		Map<String, String> userMap = (Map<String, String>) session()
				.getAttribute("findPwdMap");
		if (null == userMap || userMap.size() < 1) {
			return "stepOne";
		}
		request().setAttribute("email", userMap.get("email"));
		return SUCCESS;
	}

	/**
	 * 点击邮箱连接后
	 * 
	 * @return
	 * @throws Exception
	 */
	public String changePasswordfor() throws Exception {
		String key = SqlInfusion.FilteSqlInfusion(request("key").trim());
		String msg = "邮箱验证失败";
		String[] keys = key.split("\\$");
		if (2 == keys.length) {
			DesSecurityUtil des = new DesSecurityUtil();
			Long userId = Convert
					.strToLong(des.decrypt(keys[0].toString()), -1);
			/*
			 * String userId =
			 * Encrypt.MD5(key+IConstants.BBS_SES_KEY).substring(0,10)+key; long
			 * userIdLong = Convert.strToLong(userId, -1);
			 */
			if (userId < 0) {
				msg = "抱歉，您此次重置密码失败";
				request().setAttribute("msg1", msg);
				request().setAttribute("msg2", "请稍后重试或者联系客服");
				request().setAttribute("type", 2);
				return "index";
			}
			Map<String, String> userMap = userService.queryUserById(userId);
			// Long userId = Convert
			// .strToLong(des.decrypt(keys[0].toString()), -1);
			String dateTime = des.decrypt(keys[1].toString());
			long curTime = new Date().getTime();
			// 当用户点击注册时间小于24小时
			if (curTime - Long.valueOf(dateTime) < 24 * 60 * 60 * 1000) {
				// ServletActionContext.getRequest().setAttribute("userId",
				// userId);
				request().setAttribute("userName", userMap.get("username"));
				return SUCCESS;
			} else {
				msg = "抱歉，该链接已失效";
				request().setAttribute("msg1", msg);
				request().setAttribute("msg2", "该激活链接已超时失效，请稍后重试或者联系客服");
				request().setAttribute("type", 2);
				// ServletActionContext.getRequest().setAttribute("msg", msg);
				return "index";
			}

		} else {
			msg = "抱歉，您此次重置密码失败";
			request().setAttribute("msg1", msg);
			request().setAttribute("msg2", "请稍后重试或者联系客服");
			request().setAttribute("type", 2);
			return "index";
		}

	}

	/**
	 * 修改论坛密码
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updatechangePasswordfor() throws Exception {
		String password = SqlInfusion.FilteSqlInfusion(paramMap
				.get("newPassword"));
		String confirmpassword = SqlInfusion.FilteSqlInfusion(paramMap
				.get("confirmpassword"));
		String key = SqlInfusion.FilteSqlInfusion(paramMap.get("userId"));
		String msg = "邮箱验证失败";
		Long userId = -1l;
		String mdKey = key.substring(0, 10);
		String mdValue = key.substring(10, key.length());
		String mdCompare = Encrypt.MD5(mdValue + IConstants.BBS_SES_KEY)
				.substring(0, 10);
		if (!mdKey.equals(mdCompare)) {
			JSONUtils.printStr("4");
			return null;
		}
		String[] keys = mdValue.split("\\$");
		if (2 == keys.length) {
			DesSecurityUtil des = new DesSecurityUtil();
			userId = Convert.strToLong(des.decrypt(keys[0].toString()), -1);
			String dateTime = des.decrypt(keys[1].toString());
			long curTime = new Date().getTime();
			// 当用户点击注册时间小于10分钟
			if (curTime - Long.valueOf(dateTime) >= 10 * 60 * 1000) {
				JSONUtils.printStr("4");
				return null;
			}
		} else {
			JSONUtils.printStr("4");
			return null;
		}
		if (StringUtils.isBlank(password)) {
			JSONUtils.printStr("3");
			return null;
		}

		if (!confirmpassword.equals(password)) {
			JSONUtils.printStr("5");
			return null;
		}
		// 验证密码的长度
		if (password.length() < 6 || password.length() > 20) {
			JSONUtils.printStr("6");
			return null;
		}

		// Long userId = Convert.strToLong(paramMap.get("userId"), -1L);
		if (userId == null || userId == -1L) {
			JSONUtils.printStr("4");
			return null;
		}
		Long result = -1L;
		if (password != null && password.trim() != "" && userId != null
				&& userId != -1L) {
			result = userService.updateUserPassword(userId, password);
		}
		if (result > 0) {
			Map<String, String> userMap = userService.queryUserById(userId);
			String userName = userMap.get("username") + "";
			// 修改论坛的密码
			bbsRegisterService.doUpdatePwdByAsynchronousMode(userName,
					password, confirmpassword, 2);
			JSONUtils.printStr("1");
			return null;
		} else {
			JSONUtils.printStr("0");
			return null;
		}

	}

	// -------add by houli 将查询推荐人方法单独出来，注册填写推荐人的时候，用户要求失去焦点进行提示推荐人填写正确与否
	public String queryValidRecommer() throws Exception {
		String refferee = SqlInfusion.FilteSqlInfusion(request("refferee"));
		try {
			if (refferee == null) {
				JSONUtils.printStr("1");
				return null;
			}
			Map<String, String> reffereeTypeMap = userService
					.queryRefferee(refferee);
			if (reffereeTypeMap == null) {
				JSONUtils.printStr("1");
				return null;
			}
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
		}
		return null;
	}

	// ------------end by houli
	/**
	 * @Title: registerFirst
	 * 
	 * @Description: (注册第一步，填写用户和密码并校验)
	 * 
	 * @return String
	 * @throws Exception
	 */
	public String registerFirst() throws Exception {
		JSONObject obj = new JSONObject();
		String pageId = SqlInfusion.FilteSqlInfusion(paramMap.get("pageId")); // 验证码
		String userName = SqlInfusion
				.FilteSqlInfusion(paramMap.get("userName")); // 用户名
		if (userName.length() < 2 || userName.length() > 20) {
			obj.put("mailAddress", "1");// 用户名长度为2-20个字符
			JSONUtils.printObject(obj);
			return null;
		}
		if (StringUtils.isBlank(userName)) {
			obj.put("mailAddress", "2");// 用户名不能为空
			JSONUtils.printObject(obj);
			return null;
		}
		// 验证用户名木含有特殊字符串处理第一个字符不可以是下划线开始 ^[^@\/\'\\\"#$%&\^\*]+$
		if (userName.replaceAll("^[\u4E00-\u9FA5A-Za-z0-9_]+$", "").length() != 0) {
			obj.put("mailAddress", "3");// 用户名不能含有特殊字符
			JSONUtils.printObject(obj);
			return null;
		}
		// 判断第一个字符串不能使以下划线开头的
		String fristChar = userName.substring(0, 1);
		if (fristChar.equals("_")) {
			obj.put("mailAddress", "4");// 用户名不能以下划线开头
			JSONUtils.printObject(obj);
			return null;
		}
		if (StringUtils.isNotBlank(userName)) {
			long results = userService.isExistEmailORUserName(null, userName);
			if (results > 0) {
				obj.put("mailAddress", "0");// 用户名存在
				JSONUtils.printObject(obj);
				return null;
			} else {
				// ---add by houli 首先检查用户表中是否有重复的名字，如果没有则去t_admin表中
				Map<String, String> map = adminService.queryIdByUser(userName);
				if (map != null && map.size() > 0) {
					obj.put("mailAddress", "0");// 用户名存在
					JSONUtils.printObject(obj);
					return null;
				}
			}
		}
		String password = SqlInfusion
				.FilteSqlInfusion(paramMap.get("password")); // 用户密码
		String md5Password = password;
		if (StringUtils.isBlank(password)) {
			obj.put("mailAddress", "5");// 密码不能为空
			JSONUtils.printObject(obj);
			return null;
		}
		String confirmPassword = SqlInfusion.FilteSqlInfusion(paramMap
				.get("confirmPassword")); // 用户确认密码
		if (StringUtils.isBlank(confirmPassword)) {
			obj.put("mailAddress", "6");// 确认密码不能为空
			JSONUtils.printObject(obj);
			return null;
		}
		// 判断密码是否一致
		if (!password.equals(confirmPassword)) {
			obj.put("mailAddress", "7");// 两次输入的密码不一致
			JSONUtils.printObject(obj);
			return null;
		}
		// add by hejiangfeng 增加在注册的时候录入验证码
		String code = (String) session().getAttribute(pageId + "_checkCode");
		String _code = SqlInfusion.FilteSqlInfusion(paramMap.get("code")
				.toString().trim());
		if (code == null || !_code.equals(code)) {
			obj.put("_checkCode", "1"); // 验证码错误
			JSONUtils.printObject(obj);
			return null;
		}
		// 第一步只是验证用户和密码，直接保存用户接下来再验证邮箱或者手机
		if ("1".equals(IConstants.ENABLED_PASS)) {
			md5Password = com.shove.security.Encrypt.MD5(md5Password.trim());
		} else {
			md5Password = com.shove.security.Encrypt.MD5(md5Password.trim()
					+ IConstants.PASS_KEY);
		}
		// TODO 校验邀请人是否存在
		String refferee = SqlInfusion
				.FilteSqlInfusion(paramMap.get("refferee")); // 邀请人
		/* add by sunbing start */
		if (StringUtils.isNotBlank(refferee)) {
			Map<String, String> refUser = userService.queryRefferee(refferee);
			if (null == refUser) {
				obj.put("refferee", "1");
				JSONUtils.printObject(obj);
				return null;
			}
		}

		/* add by sunbing end */
		Long userId = -1L;
		userId = userService.userRegister1("", userName, md5Password, refferee,
				null, -1, null, 0);
		if (userId < 0) {
			obj.put("mailAddress", "12");
			JSONUtils.printObject(obj);
			return null;
		} else {
			// FIXME 将成功注册的用户id和用户名存放在session中用于后面的激活操作
			User regUser = new User();
			regUser.setUserName(userName);
			regUser.setPassword(md5Password);
			session().removeAttribute("regUser");
			session().setAttribute("regUser", regUser);
			session().removeAttribute("regUserId");
			session().setAttribute("regUserId", userId);
			session().removeAttribute("regUserName");
			session().setAttribute("regUserName", userName);
			obj.put("regUserId", userId);// 若注册成功则将用户ID传回到前台页面
			JSONUtils.printObject(obj);
		}
		return SUCCESS;
	}

	/**
	 * @Title: registerSecond
	 * 
	 * @Description: 注册第二步跳转至验证账户信息界面
	 * 
	 * @return String
	 */
	public String registerSecond() {
		/* add by sunbing start */
		String changeActiveEmail = Convert.strToStr(request().getParameter(
				"changeActiveEmail"), "-1");
		String changeActiveMobile = Convert.strToStr(request().getParameter(
				"changeActiveMobile"), "-1");
		if ("-1".equals(changeActiveEmail) && "-1".equals(changeActiveMobile)) {
			changeActiveMobile = "1";
		}
		request().setAttribute("changeActiveEmail", changeActiveEmail);
		request().setAttribute("changeActiveMobile", changeActiveMobile);
		Long userId = (Long) session().getAttribute("regUserId");
		// 判断是否用户已经注册但是账户信息未验证即绑定邮箱跟手机
		User user = (User) session().getAttribute("user");
		if (userId == null || userId <= 0) {
			if (null == user) {
				return "reg";
			} else {
				session().removeAttribute("regUser");
				session().setAttribute("regUser", user);
				session().removeAttribute("regUserId");
				session().setAttribute("regUserId", user.getId());
				session().removeAttribute("regUserName");
				session().setAttribute("regUserName", user.getUserName());
				// 移除登录状态
				session().removeAttribute("user");
			}
		} else {
			if (null != user) {
				// 移除登录状态
				session().removeAttribute("user");
			}
		}
		/* add by sunbing end */

		return SUCCESS;
	}

	/**
	 * @Title: regActivateEmail
	 * 
	 * @Description: 发送验证码至邮箱
	 * 
	 * @return String
	 * @throws Exception
	 */
	public void regActivateEmail() throws Exception {
		JSONObject obj = new JSONObject();
		Long userId = (Long) session().getAttribute("regUserId");
		String userName = (String) session().getAttribute("regUserName");
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		// 组合加密验证链接
		DesSecurityUtil des = new DesSecurityUtil();
		String key1 = des.encrypt(userId.toString());
		String key2 = des.encrypt(new Date().getTime() + "");

		String url = getPath(); // request().getRequestURI();
		String VerificationUrl = url + "verificationEmial.do?email=" + email
				+ "&key=" + key1 + "$" + key2;
		// 发送验证邮件
		try {
			mailSendService.sendRegEmail(userName, email, VerificationUrl);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			obj.put("mailAddress", "0");
			JSONUtils.printObject(obj);
			e.printStackTrace();
			throw (e);
		}
		// ===截取emal后面地址
		/*
		 * int dd = email.indexOf("@"); String mailAddress = null; if (dd >= 0)
		 * { mailAddress = "mail." + email.substring(dd + 1); }
		 */
		session().setAttribute("mail", email);
		session().setAttribute("regVerificationUrl", VerificationUrl);
		obj.put("mailAddress", "1");
		JSONUtils.printObject(obj);
	}

	/**
	 * @Title: regActivateMobile
	 * 
	 * @Description: TODO(验证手机验证码是否正确)
	 * 
	 * @return String
	 * @throws IOException
	 * @throws SQLException
	 */
	public String regActivateMobile() throws IOException, SQLException {
		// 手机验证码
		String confirmTelephone = SqlInfusion
				.FilteSqlInfusion((String) session().getAttribute(
						"telephoneCode"));
		String _confirmTelephone = SqlInfusion.FilteSqlInfusion(paramMap
				.get("confirmTelephone"));
		String mobile = SqlInfusion.FilteSqlInfusion(paramMap.get("telephone"));
		Long userId = (Long) session().getAttribute("regUserId");
		if (confirmTelephone == null
				|| !_confirmTelephone.equals(confirmTelephone)) {
			JSONUtils.printStr("1"); // 手机验证码错误
			return null;
		} else {
			// 手机号码验证成功
			if (userId != null && userId > 0) {
				// 移除验证码
				session().setAttribute("telephoneCode", "");
				// 将手机号更新到新注册的用户表中z
				long result = -1;
				result = userService.updateMobilePhone(userId, mobile);
				result = userService.updateCellPhone(userId, mobile);
				// 将用户直接在注册完后直接登录
				// User user= (User) session().getAttribute("regUser");
				// 同步注册论坛系统
				// bbsRegisterService.doRegisterByAsynchronousMode(user);
				/*
				 * User user = new User(); user.setUserName("coken8");
				 * user.setPassword("11111111"); user.setEmail("abc@163.com");
				 * bbsRegisterService.doRegisterByAsynchronousMode(user);
				 */

				// user = userService.queryUserById(userId);
				if (result > 0) {
					// 发放红包
					// gameService.spliteEnvelopeNewuser(userId, mobile);

					JSONUtils.printStr("2");
				} else {
					JSONUtils.printStr("-2");// 系统异常 数据修改出错
				}
			}
		}
		return SUCCESS;
	}

	/**
	 * @Title: regVerifyEmail
	 * 
	 * @Description: 校验邮箱是否已经存在
	 * 
	 * @return
	 * @throws Exception
	 *             String
	 */
	public String regVerifyEmail() throws Exception {
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		long mailResult = userService.isExistEmailORUserName(email, null);
		if (mailResult > 0) {
			JSONUtils.printStr("-1"); // 邮箱已经存在
		} else {
			JSONUtils.printStr("1");
		}
		return null;
	}

	/**
	 * @Title: regVerifyMobile
	 * 
	 * @Description: 校验手机号是否被注册
	 * 
	 * @return
	 * @throws Exception
	 *             String
	 */
	public String regVerifyMobile() throws Exception {
		String mobile = SqlInfusion.FilteSqlInfusion(Convert.strToStr(paramMap
				.get("mobile"), ""));
		if ("".equals(mobile)) {
			JSONUtils.printStr("-2");// 手机号码获取失败
			return null;
		}
		long result1 = userService.queryUserIdByPhone(mobile);
		if (result1 > 0) {
			JSONUtils.printStr("-1");// 手机号码已经存在
			return null;
		}
		return null;
	}

	/**
	 * @Title: regSuccess
	 * 
	 * @Description: 注册成功后跳转
	 * 
	 * @return String
	 */
	public String regSuccess() {
		return SUCCESS;
	}

	/**
	 * @throws Exception
	 *             用户注册
	 * @throws SQLException
	 * @return String
	 * @throws IOException
	 * @throws MessagingException
	 * @throws
	 */
	public String register() throws Exception {
		JSONObject obj = new JSONObject();
		String pageId = SqlInfusion.FilteSqlInfusion(paramMap.get("pageId")); // 验证码

		String userName = SqlInfusion
				.FilteSqlInfusion(paramMap.get("userName")); // 用户名
		if (userName.length() < 2 || userName.length() > 20) {
			obj.put("mailAddress", "1");// 用户名长度为2-20个字符
			JSONUtils.printObject(obj);
			return null;
		}
		if (StringUtils.isBlank(userName)) {
			obj.put("mailAddress", "2");// 用户名不能为空
			JSONUtils.printObject(obj);
			return null;
		}
		// 验证用户名木含有特殊字符串处理第一个字符不可以是下划线开始 ^[^@\/\'\\\"#$%&\^\*]+$
		if (userName.replaceAll("^[\u4E00-\u9FA5A-Za-z0-9_]+$", "").length() != 0) {
			obj.put("mailAddress", "3");// 用户名不能含有特殊字符
			JSONUtils.printObject(obj);
			return null;
		}
		// 判断第一个字符串不能使以下划线开头的
		String fristChar = userName.substring(0, 1);
		if (fristChar.equals("_")) {
			obj.put("mailAddress", "4");// 用户名不能以下划线开头
			JSONUtils.printObject(obj);
			return null;
		}
		if (StringUtils.isNotBlank(userName)) {
			long results = userService.isExistEmailORUserName(null, userName);
			if (results > 0) {
				obj.put("mailAddress", "0");// 用户名存在
				JSONUtils.printObject(obj);
				return null;
			} else {
				// ---add by houli 首先检查用户表中是否有重复的名字，如果没有则去t_admin表中
				Map<String, String> map = adminService.queryIdByUser(userName);
				if (map != null && map.size() > 0) {
					obj.put("mailAddress", "0");// 用户名存在
					JSONUtils.printObject(obj);
					return null;
				}
			}
		}
		String password = SqlInfusion
				.FilteSqlInfusion(paramMap.get("password")); // 用户密码
		String md5Password = password;
		if (StringUtils.isBlank(password)) {
			obj.put("mailAddress", "5");// 密码不能为空
			JSONUtils.printObject(obj);
			return null;
		}
		String confirmPassword = SqlInfusion.FilteSqlInfusion(paramMap
				.get("confirmPassword")); // 用户确认密码
		if (StringUtils.isBlank(confirmPassword)) {
			obj.put("mailAddress", "6");// 确认密码不能为空
			JSONUtils.printObject(obj);
			return null;
		}
		// 判断密码是否一致
		if (!password.equals(confirmPassword)) {
			obj.put("mailAddress", "7");// 两次输入的密码不一致
			JSONUtils.printObject(obj);
			return null;
		}

		String yzfs = SqlInfusion.FilteSqlInfusion(paramMap.get("yzfs"));
		String telephone = SqlInfusion.FilteSqlInfusion(paramMap
				.get("telephone"));
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		if (yzfs != null && yzfs.equals("0")) {
			// 手机号验证激活账号
			if (StringUtils.isBlank(telephone)) {
				obj.put("mailAddress", "8");// 手机号不能为空
				JSONUtils.printObject(obj);
				return null;
			}

			// 查询手机号码是否存在
			long result1 = userService.queryUserIdByPhone(telephone);
			if (result1 > 0) {
				obj.put("mailAddress", "13");// 手机已绑定
				JSONUtils.printObject(obj);
				return null;
			}

			// 手机验证码
			String confirmTelephone = SqlInfusion
					.FilteSqlInfusion((String) session().getAttribute(
							"telephoneCode"));
			String _confirmTelephone = SqlInfusion.FilteSqlInfusion(paramMap
					.get("confirmTelephone"));
			if (confirmTelephone == null
					|| !_confirmTelephone.equals(confirmTelephone)) {
				obj.put("mailAddress", "9");// 手机验证码输入有误
				JSONUtils.printObject(obj);
				return null;
			}

		} else if (yzfs != null && yzfs.equals("1")) {
			// 邮箱验证激活账号
			log.info("yzfs====" + yzfs);
			if (StringUtils.isBlank(email)) {
				obj.put("mailAddress", "8");// 邮箱不能为空
				JSONUtils.printObject(obj);
				return null;
			}

			long mailResult = userService.isExistEmailORUserName(email, null);
			if (mailResult > 0) {
				obj.put("mailAddress", "81");// 邮箱已存在
				JSONUtils.printObject(obj);
				return null;
			}

		}

		String refferee = SqlInfusion
				.FilteSqlInfusion(paramMap.get("refferee"));
		Map<String, Object> map = null;
		long recommendUserId = -1;
		if (StringUtils.isNotBlank(refferee)) {
			Map<String, String> userIdMap = userService.queryIdByUser(refferee);// 根据用户查询用户明细
			/*
			 * if (userIdMap != null) { recommendUserId =
			 * Convert.strToLong(userIdMap.get("id"), -1); } map =
			 * relationService.isPromoter(refferee); if (map == null) { refferee
			 * = null; }
			 */
			if (userIdMap == null && map == null) {
				obj.put("mailAddress", "10");// 推荐人填写错误
				JSONUtils.printObject(obj);
				return null;
			}

		}

		Long userId = -1L;
		try {
			Long result = userService.isExistEmailORUserName(null, userName);
			if (result > 0) { // 用户名重复
				obj.put("mailAddress", "11");// 用户名重复
				JSONUtils.printObject(obj);
				return null;
			}

			int typelen = -1;
			if ("1".equals(IConstants.ENABLED_PASS)) {
				md5Password = com.shove.security.Encrypt
						.MD5(md5Password.trim());
			} else {
				md5Password = com.shove.security.Encrypt.MD5(md5Password.trim()
						+ IConstants.PASS_KEY);
			}
			// 调用service,注册用户 和初始化图片资料
			if (yzfs != null && yzfs.equals("0")) {
				userId = userService.userRegister1(email, userName,
						md5Password, refferee, map, typelen, telephone, 0);// 0为手机验证用户，账号直接激活为正常状态
			} else if (yzfs != null && yzfs.equals("1")) {
				userId = userService.userRegister1(email, userName,
						md5Password, refferee, map, typelen, telephone, 1);// 1为邮箱验证用户，账号置为未激活状态
			}

			if (userId < 0) { // 注册失败
				obj.put("mailAddress", "12");
				JSONUtils.printObject(obj);
				return null;
			} else {
				// 添加论坛用户
				User user = new User();
				user.setUserName(userName);
				user.setPassword(password);
				user.setEmail(email);
				bbsRegisterService.doRegisterByAsynchronousMode(user);

				if (yzfs != null && yzfs.equals("1")) {
					// 组合加密验证链接
					DesSecurityUtil des = new DesSecurityUtil();
					String key1 = des.encrypt(userId.toString());
					String key2 = des.encrypt(new Date().getTime() + "");

					String url = getPath(); // request().getRequestURI();
					String VerificationUrl = url + "verificationEmial.do?key="
							+ key1 + "$" + key2;
					// 发送验证邮件
					mailSendService.sendRegEmail(userName, email,
							VerificationUrl);
					// ===截取emal后面地址
					int dd = email.indexOf("@");
					String mailAddress = null;
					if (dd >= 0) {
						mailAddress = "mail." + email.substring(dd + 1);
					}
					session().setAttribute("mail", mailAddress);
					obj.put("mailAddress", mailAddress);
				}

				// 添加通知默认方法
				homeInfoSettingService.addNotes(userId, true, true, false);
				homeInfoSettingService.addNotesSetting(userId, true, true,
						true, true, true, true, true, false, false, false,
						false, false, false, false, false);

				JSONUtils.printObject(obj);

			}
		} catch (SQLException e) {
			obj.put("mailAddress", "16");
			JSONUtils.printObject(obj);
			e.printStackTrace();
			throw e;

		}
		JSONUtils.printStr(IConstants.USER_REGISTER_OK);
		// 注册成功后判断是否是推广注册的。
		// 修改之前的推荐
		try {
			if (recommendUserId > 0) {// 判断是否为空

				List<Map<String, Object>> list = recommendUserService
						.queryRecommendUser(null, userId, null);// 查询用户是否已经存在关系了。
				if (list != null && list.size() > 0) {// 判断之前是否已经有关系了。
					return null;
				}
				recommendUserService.addRecommendUser(userId, recommendUserId);
			}
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
		}
		if (IConstants.ISDEMO.equals("1")) {
			obj.put("mailAddress", "99");
			JSONUtils.printObject(obj);
			return null;
		}
		return null;
	}

	private long r_userId;

	public long getR_userId() {
		return r_userId;
	}

	public void setR_userId(long id) {
		r_userId = id;
	}

	// add by houli
	public void reActivateEmail() throws Exception {
		Long userId = (Long) session().getAttribute("regUserId");
		String userName = (String) session().getAttribute("regUserName");
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		int sendMailCount = Convert.strToInt(paramMap.get("sendMailCount"), -1);
		String VerificationUrl = (String) session().getAttribute(
				"regVerificationUrl");
		if (!(userId > 0 && StringUtils.isNotBlank(userName)
				&& StringUtils.isNotBlank(email) && sendMailCount > 0 && StringUtils
				.isNotBlank(VerificationUrl))) {
			JSONUtils.printStr("-1");
			return;
		}
		// Map<String, String> userMap = userService.queryPassword(email);
		/*
		 * if (userMap == null || userMap.isEmpty()) { // 组合加密验证链接
		 * DesSecurityUtil des = new DesSecurityUtil(); String key1 =
		 * des.encrypt(userId.toString()); String key2 = des.encrypt(new
		 * Date().getTime() + "");
		 * 
		 * String url = getPath(); // request().getRequestURI(); String
		 * VerificationUrl = url + "verificationEmial.do?email="+email+"&key=" +
		 * key1 + "$" + key2;
		 */
		// 发送验证邮件
		try {
			mailSendService.sendRegEmail(userName, email, VerificationUrl);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			JSONUtils.printStr("-1");
			e.printStackTrace();
			throw (e);
		}
		// ===截取emal后面地址
		/*
		 * int dd = email.indexOf("@"); String mailAddress = null; if (dd >= 0)
		 * { mailAddress = "mail." + email.substring(dd + 1); }
		 */
		session().setAttribute("mail", email);
		sendMailCount++;
		JSONUtils.printStr(sendMailCount + "");
		/*
		 * } else { JSONUtils.printStr("0"); }
		 */

		/*
		 * String email = SqlInfusion.FilteSqlInfusion(request("email") == null
		 * ? null : Convert.strToStr( request("email"), null));
		 */
		/*
		 * try { if (email == null) { JSONUtils.printStr("1"); return INPUT; }
		 */

		// Pattern p = Pattern
		// .compile("^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
		// Matcher matcher = p.matcher(email);
		// if (!matcher.matches()) {
		// return INPUT;
		// }

		/*
		 * long id = -100; // 根据邮件查询用户信息 Map<String, String> userMap =
		 * userService.queryPassword(email); if (userMap == null ||
		 * userMap.isEmpty()) { // 按照用户名查找 userMap =
		 * userService.queryIdByUser(email); if (userMap == null ||
		 * userMap.isEmpty()) { JSONUtils.printStr("2"); return INPUT; } else {
		 * id = userMap.get("id") == null ? -100 : Convert.strToLong(
		 * userMap.get("id"), -100); } } else { id = userMap.get("id") == null ?
		 * -100 : Convert.strToLong( userMap.get("id"), -100); }
		 * 
		 * setR_userId(id); } catch (Exception e) { e.printStackTrace(); throw
		 * e; }
		 */

		// return SUCCESS;
	}

	/**
	 * 登录BBS
	 * 
	 * @return
	 * @throws Exception
	 */
	public String loginBBS() throws Exception {
		User user = (User) session().getAttribute(IConstants.SESSION_USER);
		String referer = SqlInfusion.FilteSqlInfusion(this.request("referer"));
		if (referer == null) {
			referer = "";
		}
		if (referer.contains("tid")) {
			referer += "&highlight=";
		}
		if (user == null) {
			this.response().sendRedirect(IConstants.BBS_URL + referer);
			return null;
		}

		// 虚拟用户不能登录论坛
		if (user.getVirtual() == 1) {
			this.response().sendRedirect(IConstants.BBS_URL);
			return null;
		}

		Map<String, String> map = new HashMap<String, String>();

		map.put("username", user.getUserName());
		map.put("password", Encrypt.decryptSES(user.getEncodeP(),
				IConstants.PWD_SES_KEY));

		map.put("cookietime", "2592000");
		map.put("answer", "");
		map.put("formHash", "6a36c78f");
		map.put("loginfield", "username");
		map.put("loginmode", "");
		map.put("loginsubmit", "true");

		map.put("questionid", "0");

		map.put("referer", referer);
		map.put("styleid", "");

		map.put("k", Encrypt.encryptSES(IConstants.BBS_KEY,
				IConstants.BBS_SES_KEY));

		String strURL = IConstants.BBS_URL.endsWith("/") ? IConstants.BBS_URL
				+ "logging.jsp?action=login" : IConstants.BBS_URL
				+ "/logging.jsp?action=login";
		String html = buildForm(map, strURL, "post", "登录");
		this.response().setContentType("text/html");
		response().setCharacterEncoding("utf-8");
		PrintWriter out = response().getWriter();
		out.println("<HTML>");
		out.println(" <HEAD><TITLE>sender</TITLE></HEAD>");
		out.println(" <BODY>");
		out.print(html);
		out.println(" </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
		return null;
	}

	private String buildForm(Map<String, String> sParaTemp, String gateway,
			String strMethod, String strButtonName) {
		log.info("BBS==gateway========>" + gateway);
		// 待请求参数数组
		List<String> keys = new ArrayList<String>(sParaTemp.keySet());

		StringBuffer sbHtml = new StringBuffer();

		sbHtml.append("<form id=\"loginForm\" name=\"loginForm\" action=\""
				+ gateway + "\" method=\"" + strMethod + "\">");

		for (int i = 0; i < keys.size(); i++) {
			String name = keys.get(i);
			String value = sParaTemp.get(name);
			sbHtml.append("<input type=\"hidden\" name=\"" + name
					+ "\" value=\"" + value + "\"/>");
			log.info(name + "=============" + value);
		}

		// submit按钮控件请不要含有name属性
		sbHtml.append("<input type=\"submit\" value=\"" + strButtonName
				+ "\" style=\"display:none;\"></form>");
		sbHtml.append("<script>document.forms['loginForm'].submit();</script>");

		return sbHtml.toString();
	}

	/**
	 * 登录初始化
	 * 
	 * @return String
	 * @throws
	 */
	public String loginInit() {
		User user = (User) session().getAttribute("user");
		if (user != null) {
			if (user.getSource() == 1) {
				return "zhanghao";
			} else {
				return "jkzhanghao";
			}

		}
		return SUCCESS;
	}

	/**
	 * 验证用户名和邮箱的唯一性
	 * 
	 * @return String
	 * @throws Exception
	 */
	public String ajaxCheckRegister() throws Exception {
		try {
			String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email")); // 电子邮箱
			String userName = SqlInfusion.FilteSqlInfusion(paramMap
					.get("userName")); // 用户名
			String flag = SqlInfusion.FilteSqlInfusion(paramMap.get("flag"));

			Long result = -1L;

			// 判断邮箱是否唯一
			if (StringUtils.isNotBlank(email) && StringUtils.isBlank(flag)) {
				result = userService.isExistEmailORUserName(email, null);
				if (result > 0) {
					JSONUtils.printStr(IConstants.USER_REGISTER_REPEAT_EMAIL);
				} else {
					JSONUtils.printStr("0");
				}
				return null;
			}

			// 判断用户名是否唯一
			if (StringUtils.isNotBlank(userName) && StringUtils.isBlank(flag)) {
				result = userService.isExistEmailORUserName(null, userName);
				if (result > 0) {
					JSONUtils.printStr(IConstants.USER_REGISTER_REPEAT_NAME);
				} else {
					// ---add by houli 首先检查用户表中是否有重复的名字，如果没有则去t_admin表中
					Map<String, String> map = adminService
							.queryIdByUser(userName);
					if (map == null || map.size() <= 0) {
						JSONUtils.printStr("0");
					} else {
						JSONUtils
								.printStr(IConstants.USER_REGISTER_REPEAT_NAME);
					}
				}
				return null;
			}

			// 判断邮箱与用户名是否对应存在
			if (StringUtils.isNotBlank(flag) && StringUtils.isNotBlank(email)
					&& StringUtils.isNotBlank(userName)) {
				result = userService.isExistEmailORUserName(email, userName);
				if (result > 0) {
					JSONUtils.printStr("1");

				} else {
					JSONUtils.printStr("0");
				}
			}

		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			throw e;
		}

		return null;
	}

	/**
	 * 用户登录时候的用户名和邮箱验证是否已将激活
	 * 
	 * @throws Exception
	 */
	public String ajaxChecklogin() throws Exception {
		try {
			String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email")); // 电子邮箱
			String userName = SqlInfusion.FilteSqlInfusion(paramMap
					.get("userName")); // 用户名
			String flag = SqlInfusion.FilteSqlInfusion(paramMap.get("flag"));
			String cellphone = SqlInfusion.FilteSqlInfusion(paramMap
					.get("cellphone")); // 用户名
			// 判断邮箱是否唯一
			Long result = -1L;
			Long vidResult = -1L;
			if (StringUtils.isNotBlank(email) && StringUtils.isBlank(flag)) {
				// 检测enable 没有有账号激活的
				result = userService.isUEjihuo(email, null);
				// 不检测enable 检测有没这个账号
				vidResult = userService.isUEjihuo_(email, null);
				if (vidResult < 0) {
					// 没有这个账号
					JSONUtils.printStr("0");
					return null;
					// 有邮箱 但是没有激活
				} else if (result > 0) {
					JSONUtils.printStr("1");
					return null;
				}
				JSONUtils.printStr("4");
				return null;
			}

			// 判断用户名是否唯一
			if (StringUtils.isNotBlank(userName) && StringUtils.isBlank(flag)) {
				// 检测enable 没有有账号激活的
				result = userService.isUEjihuo(null, userName);
				// 不检测enable 检测有没这个账号
				vidResult = userService.isUEjihuo_(null, userName);
				if (vidResult < 0) {
					// 没有这个账号
					JSONUtils.printStr("2");
					return null;
					// 有号 但是没有激活
				} else if (result > 0) {
					JSONUtils.printStr("3");
					return null;
				}
				JSONUtils.printStr("4");
				return null;
			}

			if (StringUtils.isNotBlank(cellphone) && StringUtils.isBlank(flag)) {
				// 检测enable 没有有账号激活的
				// 不检测enable 检测有没这个账号
				vidResult = userService.isPhoneExist(cellphone);
				if (vidResult < 0) {
					// 没有这个账号
					JSONUtils.printStr("5");
					return null;
				}
				JSONUtils.printStr("4");
				return null;
			}
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
			throw e;
		}

		return null;
	}

	/**
	 * 用户登录
	 * 
	 * @return String
	 * @throws Exception
	 */
	public String login() throws Exception {
		DateFormat dateformat = new SimpleDateFormat(UtilDate.simple);
		String email = SqlInfusion.FilteSqlInfusion(paramMap.get("email"));
		String password = SqlInfusion
				.FilteSqlInfusion(paramMap.get("password"));
		String isSave = SqlInfusion.FilteSqlInfusion(paramMap.get("isSave"));
		String afterLoginUrl = SqlInfusion.FilteSqlInfusion(paramMap
				.get("afterLoginUrl"));
		String lastIP = ServletUtils.getRemortIp();
		String lastTime = dateformat.format(new Date());
		User user = (User) session().getAttribute("user");
		try {
			user = userService.userLogin1(email, password, isSave, lastIP,
					lastTime);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		if (user == null) {
			JSONUtils.printStr("3");
			return null;
		}

		// 查找数据库对象中的enable属性
		user.setEncodeP(Encrypt.encryptSES(password, IConstants.PWD_SES_KEY));
		if (user.getEnable() == 2) {
			JSONUtils.printStr("4");
			return null;
		}

		// add by tanghaifeng
		// 在首页显示用户没有读取的通知信息
		Map<String, String> mailCountMap = homeInfoSettingService
				.queryReceiveMailsTotal(user.getId());
		request().getSession().setAttribute("mailCountMap", mailCountMap);
		// 判定该用户是否有投资记录
		Map<String, String> userInvestMap = userService.getInvest(user.getId());

		session().setAttribute("user", user);
		/* add by sunbing start */
		// 安全等级标识
		int safetyCount = 1;// 默认有登录密码，及安全等级至少为20%
		// 实名认证标志（1：已验证，0：为验证）
		if (1 == user.getIsBindIdNo()) {
			safetyCount++;
		}
		// 手机绑定标志
		if (1 == user.getIsBindMobile()) {
			safetyCount++;
		}
		// 支付密码与登录密码是否一致标志
		if (1 == user.getCode()) {
			safetyCount++;
		}
		// 密保问题
		// 根据用户ID查询
		Map<String, String> map = userService.queryQuestion(user.getId());
		if (null != map && map.size() > 1) {
			safetyCount++;
			session().setAttribute("isBindQuestion", 1);
		} else {
			session().setAttribute("isBindQuestion", 0);
		}
		//
		if ("".equals(user.getEmail()) || null == user.getEmail()) {
			session().setAttribute("isBindEmail", 0);
		} else {
			session().setAttribute("isBindEmail", 1);
		}
		double safetyLevel = (double) (Math.round((double) safetyCount * 100) / 5.0);
		session().setAttribute("safetyLevel", safetyLevel);
		/* add by sunbing end */
		if (StringUtils.isEmpty(afterLoginUrl)) {
			if (user.getSafeFlag() == 0 || userInvestMap == null) {
				// 需修改（区分新注册用户）
				/* add by sunbing start */
				// 判断账户信息是否验证，为验证需调到验证页面registerSec.do
				if (StringUtils.isEmpty(user.getEmail())
						&& 1 != user.getIsBindMobile()) {
					JSONUtils.printStr("7");
				} else {
					JSONUtils.printStr("5");
				}
				/* add by sunbing end */
			} else {
				JSONUtils.printStr("6");
			}
		} else {
			JSONUtils.printStr("1");
		}
		// 刷新登录计数
		userService.loginCountReFresh(user.getId());
		// 用户登录日志插入
		if (user.getId() > 0) {
			userIntegralService.addUserLoginLog(user.getId());
		}
		// 用户登录分数
		Map<String, String> Logmap = null;
		Map<String, String> Usermap = null;
		Integer preScore = null;
		int LongCount = 1;
		int score = 1;
		if (user.getId() > 0) {
			Logmap = userIntegralService.queryUserLoginLong(user.getId());
			Usermap = userService.queryUserById(user.getId());
			if (Logmap.size() > 0 && Logmap != null) {
				preScore = Convert.strToInt(Usermap.get("rating"), 0);
				LongCount = Convert.strToInt(Logmap.get("cl"), 0);
				userIntegralService.UpdateLoginRating(user.getId(), score,
						preScore, LongCount);

			}
		}

		return null;
	}

	/**
	 * @Title: loginAfterReg
	 * 
	 * @Description: 注册后直接登录，初始化登录信息，记录日志等
	 * 
	 * @return String
	 * @throws Exception
	 */
	public String loginAfterReg() throws Exception {
		int type = Convert.strToInt(request().getParameter("type"), -1);
		DateFormat dateformat = new SimpleDateFormat(UtilDate.simple);
		String lastIP = ServletUtils.getRemortIp();
		String lastTime = dateformat.format(new Date());
		User user = (User) session().getAttribute("user"); // 获取登录的用户session
		User regUser = (User) session().getAttribute("regUser"); // 获取刚刚注册的用户session
		/* edit by sunbing start userLogin-->userLogin1 */
		user = userService.userLogin2(regUser.getUserName(), regUser
				.getPassword(), lastIP, lastTime);
		/* edit by sunbing end */
		// 在首页显示用户没有读取的通知信息
		Map<String, String> mailCountMap;
		mailCountMap = homeInfoSettingService.queryReceiveMailsTotal(user
				.getId());
		request().getSession().setAttribute("mailCountMap", mailCountMap);
		// 判定该用户是否有投资记录
		Map<String, String> userInvestMap = userService.getInvest(user.getId());

		session().setAttribute("user", user);
		if (user.getSafeFlag() == 0 || userInvestMap == null) {
			// JSONUtils.printStr("5");
		} else {
			// JSONUtils.printStr("1");
		}
		// 刷新登录计数
		userService.loginCountReFresh(user.getId());

		// 用户登录日志插入
		if (user.getId() > 0) {
			userIntegralService.addUserLoginLog(user.getId());
		}
		// 用户登录分数
		Map<String, String> Logmap = null;
		Map<String, String> Usermap = null;
		Integer preScore = null;
		int LongCount = 1;
		int score = 1;
		if (user.getId() > 0) {
			Logmap = userIntegralService.queryUserLoginLong(user.getId());
			Usermap = userService.queryUserById(user.getId());
			if (Logmap.size() > 0 && Logmap != null) {
				preScore = Convert.strToInt(Usermap.get("rating"), 0);
				LongCount = Convert.strToInt(Logmap.get("cl"), 0);
				userIntegralService.UpdateLoginRating(user.getId(), score,
						preScore, LongCount);
			}
		}
		if (type == 1) {
			return "recharge";
		} else if (type == 3) {
			return "xsInvest";
		} else {
			return SUCCESS;
		}
	}

	public String queryMailCount() throws Exception {
		User user = (User) session().getAttribute("user");
		if (user == null) {
			return null;
		}
		// 在首页显示用户没有读取的通知信息
		Map<String, String> mailCountMap = homeInfoSettingService
				.queryReceiveMailsTotal(user.getId());
		// request().getSession().setAttribute("mailCountMap", mailCountMap);
		String mailTotal = mailCountMap.get("mailTotal");
		if (null != mailTotal) {
			JSONUtils.printStr(mailTotal);
		} else {
			JSONUtils.printStr("0");
		}
		return null;
	}

	public String queryUserInvest() throws Exception {
		User user = (User) session().getAttribute("user");
		if (user == null) {
			return null;
		}
		// 在首页显示投资助手
		Map<String, String> userInvestMap = userService.getInvest(user.getId());

		if (null != userInvestMap) {
			JSONUtils.printStr("1");
			request().getSession().setAttribute("isInvest", "1");
		} else {
			JSONUtils.printStr("-1");
			request().getSession().setAttribute("isInvest", "0");
		}
		return null;
	}

	/**
	 * 验证邮箱
	 * 
	 * @return
	 * @throws Exception
	 * @throws Exception
	 */
	public String verificationEmial() throws Exception {
		String email = SqlInfusion.FilteSqlInfusion(request("email").trim());
		String key = SqlInfusion.FilteSqlInfusion(request("key").trim());
		String msg = "邮箱验证失败";
		String[] keys = key.split("\\$");
		if (2 == keys.length) {
			DesSecurityUtil des = new DesSecurityUtil();
			Long userId = Convert
					.strToLong(des.decrypt(keys[0].toString()), -1);

			String dateTime = des.decrypt(keys[1].toString());
			long curTime = new Date().getTime();
			// 当用户点击注册时间小于10分钟
			if (curTime - Long.valueOf(dateTime) < 10 * 60 * 1000) {
				// add by hejiangfeng 用户绑定邮箱
				Long result1 = userService.updateEmalByid(userId, email);
				// 修改用户状态
				Long result = userService.frontVerificationEmial(userId);
				/* add by sunbing start */
				// 查询用户信息
				Map<String, String> userMap = userService.queryUserById(userId);
				User regUser = new User();
				regUser.setPassword(userMap.get("password"));
				regUser.setUserName(userMap.get("username"));
				session().setAttribute("regUser", regUser);
				session().setAttribute("regUserName", regUser.getUserName());
				/* add by sunbing end */
				if (result > 0 && result1 > 0) {
					msg = "恭喜您帐号激活成功！请点击<a href='login.do'>登录</a>";
					ServletActionContext.getRequest().setAttribute("msg", msg);
					return SUCCESS;
				} else {
					msg = "抱歉，注册失败";
					request().setAttribute("msg1", msg);
					request().setAttribute("msg2", "请稍后重试或者联系客服");
					request().setAttribute("type", 1);
					// 这里还要写一个用户删除账号和密码
					// ServletActionContext.getRequest().setAttribute("msg",
					// msg);
					return ERROR;
				}
			} else {
				msg = "抱歉，该链接已经失效";
				request().setAttribute("msg1", msg);
				request().setAttribute("msg2", "该激活链接已超时失效，请重新激活");
				request().setAttribute("type", 1);
				// ServletActionContext.getRequest().setAttribute("msg", msg);
				return ERROR;
			}
		} else {
			msg = "抱歉，注册失败";
			request().setAttribute("msg1", msg);
			request().setAttribute("msg2", "请稍后重试或者联系客服");
			request().setAttribute("type", 1);
			return ERROR;
		}
	}

	/**
	 * 重新发送邮件
	 * 
	 * @throws Exception
	 */
	public String reSendEmail() throws Exception {
		DesSecurityUtil des = new DesSecurityUtil();
		String key1 = des.encrypt(ServletActionContext.getRequest()
				.getParameter("id"));
		String key2 = des.encrypt(new Date().getTime() + "");
		String url = getPath(); // request().getRequestURI();
		String VerificationUrl = url + "verificationEmial.do?key=" + key1 + "$"
				+ key2;
		long userId = Convert.strToLong(ServletActionContext.getRequest()
				.getParameter("id"), -1);
		// 获取用户email地址 和 userName
		Map<String, String> reMap = null;

		reMap = userService.queryUserById(userId);

		if (null != reMap && reMap.size() > 0) {
			String userName = reMap.get("username");
			String email = reMap.get("email");
			// 发送验证邮件
			mailSendService.sendRegEmail(userName, email, VerificationUrl);
			// sendMailService.sendRegisterVerificationEmail(VerificationUrl,userName,
			// email);
			int dd = email.indexOf("@");
			String mailAddress = null;
			if (dd >= 0) {
				mailAddress = "mail." + email.substring(dd + 1);
			}
			request().setAttribute("emaladdresss", mailAddress);
		}
		return SUCCESS;
	}

	/**
	 * 邮箱提示信息跳转
	 */
	public String tip() {
		Long userId = (Long) session().getAttribute("regUserId");
		String email = (String) session().getAttribute("mail");
		if (userId == null || userId <= 0 || StringUtils.isBlank(email)) {
			return "reg";
		}
		request().setAttribute("email", email);
		return SUCCESS;
	}

	/**
	 * 用户登录后的页面
	 * 
	 * @return
	 */
	public String jumpUser() {
		return SUCCESS;
	}

	/**
	 * 虚拟用户登录时没有权限跳转页面
	 * 
	 * @return
	 */
	public String noPermission() {
		return SUCCESS;
	}

	/**
	 * @MethodName: logout
	 * @Param: FrontLongRegisterAction
	 * @Author: gang.lv
	 * @Date: 2013-3-8 下午11:04:19
	 * @Return:
	 * @Descb: 退出系统
	 * @Throws:
	 */
	public void logout() throws Exception {

		Cookie[] cookies = request().getCookies();
		if (cookies != null) {
			for (int i = 0; i < cookies.length; i++) {
				if (cookies[i].getName().equals("cookie_user")) {
					cookies[i].setMaxAge(0);
					response().addCookie(cookies[i]);
					break;
				}
			}

		}
		// HttpServletResponse response=ServletActionContext.getResponse();
		request().getSession().removeAttribute("user");
		request().getSession().invalidate();
		session().removeAttribute("user");
		session().invalidate();
		session().removeAttribute("bbs");
		bbsRegisterService.doExitByAsynchronousMode();
		getOut().print("<script>parent.location.href='login.do';</script>");
		// 移除bbs cookie
		HttpServletResponse response = ServletActionContext.getResponse();
		Cookie cookie = new Cookie("gofullAutoLogin", "");
		cookie.setDomain(".gofull.com.cn");
		cookie.setMaxAge(0); // delete the cookie.
		response.addCookie(cookie);

	}

	public void setSendMailService(SendMailService sendMailService) {
		this.sendMailService = sendMailService;
	}

	public RecommendUserService getRecommendUserService() {
		return recommendUserService;
	}

	public void setRecommendUserService(
			RecommendUserService recommendUserService) {
		this.recommendUserService = recommendUserService;
	}

	public void setRelationService(RelationService relationService) {
		this.relationService = relationService;
	}

	public HomeInfoSettingService getHomeInfoSettingService() {
		return homeInfoSettingService;
	}

	public void setHomeInfoSettingService(
			HomeInfoSettingService homeInfoSettingService) {
		this.homeInfoSettingService = homeInfoSettingService;
	}

	public void setBbsRegisterService(BBSRegisterService bbsRegisterService) {
		this.bbsRegisterService = bbsRegisterService;
	}

	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}

	/**
	 * 发送短信验证，手机注册
	 * 
	 * @param telephone
	 *            前台传入手机号码
	 * @return 1发送成功 -1获取手机号码失败 -2手机号码已存在
	 * @throws Exception
	 */
	public String sendCodeToTelphone() throws Exception {
		String pageId = SqlInfusion.FilteSqlInfusion(paramMap.get("pageId")); // 验证码
		String code = (String) session().getAttribute(pageId + "_checkCode");
		String _code = SqlInfusion.FilteSqlInfusion(Convert.strToStr(paramMap
				.get("code"), "").toString().trim());
		if (null == code || !_code.equals(code)) {
			JSONUtils.printStr("-3");
			return null;
		}

		// 获取前台提交手机号码
		String telephone = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("telephone"), ""));
		if (null == telephone) {
			JSONUtils.printStr("-1");// 获取手机号码失败
			return null;
		}
		// 查询手机号码是否存在
		long result1 = userService.queryUserIdByPhone(telephone);
		if (result1 > 0) {
			JSONUtils.printStr("-2");// 手机号码已经存在
			return null;
		}

		StringBuffer telephoneCode = new StringBuffer();
		// 获取验证码
		for (int i = 0; i < 6; i++) {
			telephoneCode.append((int) (Math.random() * 10));
		}
		session().setAttribute("telephoneCode", telephoneCode.toString());
		// 记录当前时间
		long sendTime = System.currentTimeMillis();
		session().setAttribute("sendTimeLast", sendTime);
		System.out.println(telephoneCode.toString());

		Map<String, String> map = sMsService.getSMSById(1);

		SMSUtil.sendSMS(map.get("Account"), map.get("Password"),
				"欢迎注册共富网，短信验证码为:" + telephoneCode.toString()
						+ "（请在页面输入以完成验证），如非本人操作，请忽略本短信。有问题请致电：4008-893-983",
				telephone, "");

		JSONUtils.printStr("1");// 发送验证码成功

		return null;
	}

	/**
	 * 重新发送短信验证，手机注册
	 * 
	 * @param telephone
	 *            前台传入手机号码
	 * @return 1发送成功 -1获取手机号码失败 -2手机号码已存在-3时间相隔未到1min
	 * @throws Exception
	 */
	public void sendCodeToTelphoneAgain() throws Exception {
		/* add by sunbing start */
		long sendTimeLast = (Long) session().getAttribute("sendTimeLast");
		long sendTimeLastNow = System.currentTimeMillis();
		long cost = sendTimeLastNow - sendTimeLast;
		if (sendTimeLast == 0 || cost < 1 * 60 * 1000) {
			JSONUtils.printStr("-3");
			return;
		}
		/* add by sunbing end */

		// 获取前台提交手机号码
		String telephone = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("telephone"), null));
		if (telephone == null) {
			JSONUtils.printStr("-1");// 获取手机号码失败
			return;
		}
		// 查询手机号码是否存在
		long result1 = userService.queryUserIdByPhone(telephone);
		if (result1 > 0) {
			JSONUtils.printStr("-2");// 手机号码已经存在
			return;
		}

		StringBuffer telephoneCode = new StringBuffer();
		// 获取验证码
		for (int i = 0; i < 6; i++) {
			telephoneCode.append((int) (Math.random() * 10));
		}
		session().setAttribute("telephoneCode", telephoneCode.toString());
		session().setAttribute("sendTimeLast", sendTimeLastNow);
		System.out.println(telephoneCode.toString());

		Map<String, String> map = sMsService.getSMSById(1);

		SMSUtil.sendSMS(map.get("Account"), map.get("Password"),
				"欢迎注册共富网，短信验证码为:" + telephoneCode.toString()
						+ "（请在页面输入以完成验证），如非本人操作，请忽略本短信。有问题请致电：4008-893-983",
				telephone, "");

		JSONUtils.printStr("1");// 发送验证码成功

	}

	/**
	 * 发送短信验证,绑定手机
	 * 
	 * @param telephone
	 *            前台传入手机号码
	 * @return 1发送成功 -1获取手机号码失败 -2手机号码已存在
	 * @throws Exception
	 */
	public String telephoneCode() throws Exception {

		// 获取前台提交手机号码
		String telephone = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("telephone"), null));
		if (telephone == null) {
			JSONUtils.printStr("-1");// 获取手机号码失败
			return null;
		}
		// 查询手机号码是否存在
		long result1 = userService.queryUserIdByPhone(telephone);
		if (result1 > 0) {
			JSONUtils.printStr("-2");// 手机号码已经存在
			return null;
		}

		StringBuffer telephoneCode = new StringBuffer();
		// 获取验证码
		for (int i = 0; i < 6; i++) {
			telephoneCode.append((int) (Math.random() * 10));
		}
		session().setAttribute("telephoneCode", telephoneCode.toString());

		System.out.println(telephoneCode.toString());

		Map<String, String> map = sMsService.getSMSById(1);

		SMSUtil.sendSMS(map.get("Account"), map.get("Password"), "您的验证码为"
				+ telephoneCode.toString()
				+ "（请在页面输入以完成验证），如非本人操作，请忽略本短信。有问题请致电：4008-893-983", telephone,
				"");

		JSONUtils.printStr("1");// 发送验证码成功

		return null;
	}

	/***
	 * 获取验证码（借款人绑定手机）
	 * 
	 * @return
	 * @throws ServiceException
	 * @throws IOException
	 */
	public String getCode() throws Exception {

		// String pageId =SqlInfusion.FilteSqlInfusion( paramMap.get("pageId"));
		// // 验证码
		// String code = (String) session().getAttribute(pageId + "_checkCode");
		/*
		 * String _code =
		 * SqlInfusion.FilteSqlInfusion((paramMap.get("code")+"").trim()); if
		 * (code == null || !_code.equals(code)) { JSONUtils.printStr("-3");
		 * return null; }
		 */

		// String
		// telephone=SqlInfusion.FilteSqlInfusion(paramMap.get("telephone"));
		// 手机号码直接从用户信息离查询
		User user = (User) session().getAttribute("user");
		Map<String, String> userMap = userService.queryUserById(user.getId());
		String telephone = userMap.get("mobilePhone");
		if (StringUtils.isEmpty(telephone)) {
			// 获取手机号码失败
			JSONUtils.printStr("0");
			return null;
		}
		StringBuffer telephoneCode = new StringBuffer();

		// 获取验证码
		for (int i = 0; i < 6; i++) {
			telephoneCode.append((int) (Math.random() * 10));
		}
		session().setAttribute("telephoneCode", telephoneCode + "");

		System.out.println(telephoneCode.toString());

		Map<String, String> map = sMsService.getSMSById(1);

		SMSUtil.sendSMS(map.get("Account"), map.get("Password"), "您的验证码为 "
				+ telephoneCode.toString()
				+ "（请在页面输入以完成验证），如非本人操作，请忽略本短信。有问题请致电：4008-893-983", telephone,
				"");

		JSONUtils.printStr("1");// 发送验证码成功

		return null;
	}

	/**
	 * @Title: checkUserAndPhone
	 * 
	 * @Description: 校验该用户是否绑定该手机号码
	 * 
	 * @return
	 * @throws Exception
	 *             String
	 */
	public String checkUserAndPhone() throws Exception {
		String username = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("username"), null)); // 用户名
		if (username == null) {
			JSONUtils.printStr("-2");// 获取用户名失败
			return null;
		}
		// 获取前台提交手机号码
		String telephone = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("telephone"), null));
		if (telephone == null) {
			JSONUtils.printStr("-1");// 获取手机号码失败
			return null;
		}
		Map<String, String> userMap = userService
				.queryUserBymobilePhone(telephone);
		if (userMap == null || !userMap.get("username").equals(username)) {
			JSONUtils.printStr("-2");// 手机号码不存在或非本用户绑定手机号
			return null;
		}
		return null;
	}

	public void checkUserAndEmail() throws Exception {
		String username = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("username"), null)); // 用户名
		if (username == null) {
			JSONUtils.printStr("-2");// 获取用户名失败
			return;
		}
		// 获取前台提交手机号码
		String email = SqlInfusion.FilteSqlInfusion(Convert.strToStr(paramMap
				.get("email"), null));
		if (email == null) {
			JSONUtils.printStr("-1");// 获取手机号码失败
			return;
		}
		Map<String, String> userMap = userService.queryUserByEmail(email);
		if (userMap == null || !userMap.get("username").equals(username)) {
			JSONUtils.printStr("-2");// 手机号码不存在或非本用户绑定手机号
		}
	}

	/**
	 * 发送短信验证
	 * 
	 * @param telephone
	 *            前台传入手机号码
	 * @return 1发送成功 -1获取手机号码失败 -2手机号码已存在
	 * @throws Exception
	 */
	public String getTelephoneCode() throws Exception {

		String pageId = SqlInfusion.FilteSqlInfusion(paramMap.get("pageId")); // 验证码
		String code = (String) session().getAttribute(pageId + "_checkCode");
		String username = SqlInfusion
				.FilteSqlInfusion(paramMap.get("username")); // 用户名

		// 获取前台提交手机号码
		String telephone = SqlInfusion.FilteSqlInfusion(Convert.strToStr(
				paramMap.get("telephone"), null));
		if (telephone == null) {
			JSONUtils.printStr("-1");// 获取手机号码失败
			return null;
		}

		Map<String, String> userMap = userService
				.queryUserBymobilePhone(telephone);
		if (userMap == null || !userMap.get("username").equals(username)) {
			JSONUtils.printStr("-2");// 手机号码不存在或非本用户绑定手机号
			return null;
		}

		StringBuffer telephoneCode = new StringBuffer();
		// 获取验证码
		for (int i = 0; i < 6; i++) {
			telephoneCode.append((int) (Math.random() * 10));
		}
		session().setAttribute("telephoneCode", telephoneCode.toString());

		System.out.println(telephoneCode.toString());

		Map<String, String> map = sMsService.getSMSById(1);
		SMSUtil.sendSMS(map.get("Account"), map.get("Password"), "您的验证码是"
				+ telephoneCode.toString()
				+ "（请在页面输入以完成验证），如非本人操作，请忽略本短信。有问题请致电：4008-893-983", telephone,
				"");

		JSONUtils.printStr("1");// 发送验证码成功

		return null;
	}

	/**
	 * 发送短信验证
	 * 
	 * @param telephone
	 *            前台传入手机号码
	 * @return 1发送成功 -1获取手机号码失败 -2手机号码已存在
	 * @throws Exception
	 */
	public String checkTelephoneCode() throws Exception {
		// 获取前台提交手机验证码
		String code = SqlInfusion.FilteSqlInfusion(Convert.strToStr(paramMap
				.get("code"), null));
		if (code == null || code == "") {
			JSONUtils.printStr("-1");// 获取验证码失败
			return null;
		}
		String telephoneCode = new String();
		telephoneCode = (String) session().getAttribute("telephoneCode");
		if (telephoneCode == null || telephoneCode == "") {
			JSONUtils.printStr("-2");// 系统异常
			return null;
		}
		if (!code.equals(telephoneCode)) {
			JSONUtils.printStr("-1");// 验证失败
		}
		if (code.equals(telephoneCode)) {
			session().setAttribute("checkTelephoneCode", true);
			JSONUtils.printStr("1");// 验证成功
		}
		return null;
	}

	/**
	 * @Title: findPwdStepThree
	 * 
	 * @Description: 密码找回验证手机号码后跳转
	 * 
	 * @return String
	 */
	public String findPwdStepThree() {
		Map<String, String> userMap = (Map<String, String>) session()
				.getAttribute("findPwdMap");
		if (null == userMap || userMap.size() < 1) {
			return "stepOne";
		}
		if (null != session().getAttribute("checkTelephoneCode")) {
			boolean falg = (Boolean) session().getAttribute(
					"checkTelephoneCode");
			if (!falg) {
				return "stepOne";
			}
		} else {
			return "stepOne";
		}
		request().setAttribute("userName", userMap.get("username"));
		return SUCCESS;
	}

	public String updatePswSuccess() {
		return SUCCESS;
	}

	/***
	 * 修改借款人手机号码
	 * 
	 * @return
	 */
	public String updjkNewPhone() {
		User user = (User) session().getAttribute("user");
		String newCellphone = SqlInfusion.FilteSqlInfusion(paramMap
				.get("telephone"));
		try {
			if (newCellphone.equals("") || newCellphone == null) {
				JSONUtils.printStr("0");
			}

			Long result = userService.updataUserCellphone(user.getId(),
					newCellphone);

			if (result > 0) {
				JSONUtils.printStr("1");
			} else {
				JSONUtils.printStr("-1");
			}
		} catch (Exception e) {
			log.error(e);
			e.printStackTrace();
		}
		return null;
	}

}
